package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.common.BaseContext;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.ShoppingCart;
import com.itheima.reggie.entity.User;
import com.itheima.reggie.mapper.ShoppingCartMapper;
import com.itheima.reggie.mapper.UserMapper;
import com.itheima.reggie.service.ShoppingCartService;
import com.itheima.reggie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;

@Service
public class ShoppingCartServiceImpl extends
        ServiceImpl<ShoppingCartMapper,ShoppingCart> implements
        ShoppingCartService {


    @Autowired
    private ShoppingCartService shoppingCartService;

    @Transactional
    public R cleanall() {

        LambdaQueryWrapper<ShoppingCart> qwshop = new LambdaQueryWrapper<>();
        qwshop.eq(ShoppingCart::getUserId, BaseContext.getCurrentId());

        shoppingCartService.remove(qwshop);
        return R.success(null);
    }

}
